package cn.com.jrj.base.db;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.com.jrj.base.service.CustomerRoutingDataSourceService;

public class CustomerRoutingDataSourceInterceptor implements MethodInterceptor{
	
		Log log = LogFactory.getLog(getClass());

		public Object invoke(MethodInvocation invocation) throws Throwable {
			Object obj = invocation.getThis();
			if (obj instanceof CustomerRoutingDataSourceService) {
				CustomerRoutingDataSourceService service = (CustomerRoutingDataSourceService) obj;
				CustomerContextHolder.setCustomerType(service.getCustomerType());
			}
			return invocation.proceed();
		}
}
